﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using Utils;

public partial class UserControls_CHeaderControl : BaseUserControl
{
    // Fields
    protected string abbreviation = string.Empty;
    protected string cityname = string.Empty;
    protected DataTable citys = new DataTable();
    protected string cityshtml = string.Empty;
    protected int count = 0;
    protected string couponname = string.Empty;
    protected string curcityid = string.Empty;
    protected string headlogo = string.Empty;
    protected int invitecredit = 0;
    protected string menuhtml = string.Empty;
    protected bool opensmssubscribe = false;
    protected bool result = false;
    protected bool trsimple = false;

    // Methods
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        if (base.CurrentCity != null)
        {
            this.cityname = base.CurrentCity.Name;
            this.curcityid = base.CurrentCity.Id.ToString();
        }
        else
        {
            this.cityname = "全部城市";
            this.curcityid = "0";
        }
        bool flag = false;
        string absoluteUri = base.Request.Url.AbsoluteUri;
        if (absoluteUri.IndexOf("/team/index.aspx") < 0)
        {
            this.menuhtml = this.menuhtml + "<li><a href=\"/team/index.aspx\">往期团购</a></li>";
        }
        else
        {
            this.menuhtml = this.menuhtml + "<li class=\"dangqian\"><a href=\"/team/index.aspx\">往期团购</a></li>";
            flag = true;
        }
        if (base.ASSystem != null)
        {
            this.headlogo = base.ASSystem.headlogo;
            this.opensmssubscribe = Convert.ToBoolean(base.ASSystem.Smssubscribe);
            if (base.ASSystem.Navseconds > 0)
            {
                if (absoluteUri.IndexOf("/team/seconds.aspx") < 0)
                {
                    this.menuhtml = this.menuhtml + "<li><a href=\"/team/seconds.aspx\">秒杀抢团</a></li>";
                }
                else
                {
                    this.menuhtml = this.menuhtml + "<li class=\"dangqian\"><a href=\"/team/seconds.aspx\">秒杀抢团</a></li>";
                    flag = true;
                }
            }
            if (base.ASSystem.Navgoods > 0)
            {
                if (absoluteUri.IndexOf("/team/goods.aspx") < 0)
                {
                    this.menuhtml = this.menuhtml + "<li><a href=\"/team/goods.aspx\">热销商品</a></li>";
                }
                else
                {
                    this.menuhtml = this.menuhtml + "<li class=\"dangqian\"><a href=\"/team/goods.aspx\">热销商品</a></li>";
                    flag = true;
                }
            }
            if (base.ASSystem.Navpartner > 0)
            {
                if (absoluteUri.IndexOf("/partner/index.aspx") < 0)
                {
                    this.menuhtml = this.menuhtml + "<li><a href=\"/partner/index.aspx\">品牌商户</a></li>";
                }
                else
                {
                    this.menuhtml = this.menuhtml + "<li class=\"dangqian\"><a href=\"/partner/index.aspx\">品牌商户</a></li>";
                    flag = true;
                }
            }
            if (absoluteUri.IndexOf("/help") < 0)
            {
                this.menuhtml = this.menuhtml + "<li><a href=\"/help/tour.aspx\">团购达人</a></li>";
            }
            else
            {
                if (!absoluteUri.Contains("link"))
                {
                    this.menuhtml = this.menuhtml + "<li class=\"dangqian\"><a href=\"/help/tour.aspx\">团购达人</a></li>";
                }
                else
                {
                    this.menuhtml = this.menuhtml + "<li><a href=\"/help/tour.aspx\">团购达人</a></li>";
                }
                flag = true;
            }
            if (base.ASSystem.navforum > 0)
            {
                if (absoluteUri.IndexOf("/forum/index.aspx") < 0)
                {
                    this.menuhtml = this.menuhtml + "<li><a href=\"/forum/index.aspx\">讨论区</a></li>";
                }
                else
                {
                    this.menuhtml = this.menuhtml + "<li class=\"dangqian\"><a href=\"/forum/index.aspx\">讨论区</a></li>";
                    flag = true;
                }
            }
            if (base.ASSystem.Trsimple > 0)
            {
                this.trsimple = true;
            }
            this.couponname = base.ASSystem.Couponname;
            this.invitecredit = Helper.GetInt(Math.Floor(base.ASSystem.Invitecredit), 0);
            this.abbreviation = base.ASSystem.abbreviation;
        }
        if (base.ASSystem.GouwuChe > 0)
        {
            if (absoluteUri.IndexOf("/shopcart/show.aspx") < 0)
            {
                this.menuhtml = this.menuhtml + "<li><a href=\"/shopcart/show.aspx\">购物车</a></li>";
            }
            else
            {
                this.menuhtml = this.menuhtml + "<li class=\"dangqian\"><a href=\"/shopcart/show.aspx\">购物车</a></li>";
                flag = true;
            }
        }
        if ((((absoluteUri.IndexOf("/index.aspx") > 0) && !flag) && ((!absoluteUri.Contains("coupon") && !absoluteUri.Contains("credit")) && !absoluteUri.Contains("order"))) || ((absoluteUri.Contains("team.aspx") && (base.CurrentTeam != null)) && (base.CurrentTeam.Team_type == "normal")))
        {
            this.menuhtml = "<li class=\"dangqian\"><a href=\"/index.aspx\">今日团购</a></li>" + this.menuhtml;
        }
        else
        {
            this.menuhtml = "<li><a href=\"/index.aspx\">今日团购</a></li>" + this.menuhtml;
        }
        this.citys = base.CityList;
        this.count = this.citys.Rows.Count;
        for (int i = 0; i < this.citys.Rows.Count; i++)
        {
            if (this.citys.Rows[i]["Display"].ToString().ToUpper() == "Y")
            {
                if ((base.CurrentCity != null) && (base.CurrentCity.Id == Convert.ToInt32(this.citys.Rows[i]["id"])))
                {
                    this.result = true;
                    this.cityshtml = string.Concat(new object[] { this.cityshtml, "<li class=\"dangqian\"><a href=\"/city.aspx?ename=", this.citys.Rows[i]["Ename"], "\">", this.citys.Rows[i]["Name"], "</a></li>" });
                }
                else
                {
                    this.cityshtml = string.Concat(new object[] { this.cityshtml, "<li><a href=\"/city.aspx?ename=", this.citys.Rows[i]["ename"], "\">", this.citys.Rows[i]["Name"], "</a></li>" });
                }
            }
        }
    }

}